package BiTree;

/**
 * @program: java_concurrent
 * @description: 判断两棵树是否相同
 * @author: lxf
 * @create: 2024-06-22 9:27
 **/
public class IsSameTree {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) return true;
        if (p == null || q == null) return false;
        if (p.val != q.val) return false;
        return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }
}
